package com.aaa.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: TODO
 * @date 2022/11/18
 */
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket docket(){
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                //组名
                .groupName("Three groups")
                //api接口信息
                .apiInfo(getInfo())
                //选择哪些生成api接口--根据请求路径选择--根据包名选择
                .select()
                //按照指定的路径选择
                .paths(Predicates.and(PathSelectors.regex("/api/.*")))
                //按照包指定的路径选择
                .apis(RequestHandlerSelectors.basePackage("com.example.idea_spring_boot.controller"))
                .build()
                ;


        return docket;
    }
    private ApiInfo getInfo(){
        Contact DEFAULT_CONTACT = new Contact("李经理", "http://www.ljx.com", "2389453299@qq.com");
        ApiInfo defaultInfo = new ApiInfo("车站售票API", "车站售票API", "3.0", "http://www.czsp.com", DEFAULT_CONTACT, "北京中兴科技", "http://www.bjzxkj.com", new ArrayList<VendorExtension>());
        return defaultInfo;
    }
}
